package com.wv.api.server.basic;

import com.wv.api.service.basic.IBasicCommunityService;
import com.wv.common.result.Result;
import com.wv.model.basic.BasicCommunity;
import com.wv.model.basic.condition.BasicCommunityCondition;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "小区相关接口")
@RequestMapping("/community")
public class BasicCommunityController {

    @Autowired
    private IBasicCommunityService basicCommunityService;

    @PostMapping(value = "/list")
    @ApiOperation("获取小区列表")
    public Result get(@RequestBody BasicCommunityCondition basicCommunityCondition){
        return basicCommunityService.getCommunityList(basicCommunityCondition);
    }

    @PostMapping
    @ApiOperation("添加小区数据")
    public Result add(@RequestBody BasicCommunity basicCommunity){
        return basicCommunityService.addCommunity(basicCommunity);
    }

    @PutMapping
    @ApiOperation("修改小区数据")
    public Result update(@RequestBody BasicCommunity basicCommunity){
        return basicCommunityService.updateCommunity(basicCommunity);
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除小区数据")
    public Result delete(@PathVariable String id){
        return basicCommunityService.deleteCommunity(id);
    }
}
